// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   workSpace_useImg.java

package include.ajax;

import include.nseer_db.nseer_db_backup;
import include.tree_index.Nseer;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.ResultSet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;

public class workSpace_useImg extends HttpServlet
{

	ServletContext application;
	HttpSession session;
	nseer_db_backup erp_db;
	Nseer n;

	public workSpace_useImg()
	{
		erp_db = null;
		n = new Nseer();
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		ServletContext dbApplication = dbSession.getServletContext();
		try
		{
			PrintWriter out = response.getWriter();
			String sq = "";
			String cont = "";
			String cont1 = "";
			String cont2 = "";
			String cont3 = "";
			nseer_db_backup db = new nseer_db_backup(dbApplication);
			if (db.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String module_name = request.getParameter("module_name");
				if (module_name.indexOf("--") == -1)
				{
					sq = (new StringBuilder("select * from document_main where value='")).append(module_name).append("'").toString();
					ResultSet rs = db.executeQuery(sq);
					if (rs.next())
					{
						String url = (new StringBuilder("images/erpPlatform/design/")).append(rs.getString("picture")).toString();
						out.println(url);
					}
				} else
				{
					String main_module = module_name.split("--")[0];
					sq = (new StringBuilder("select * from document_main where value='")).append(main_module).append("'").toString();
					ResultSet rs = db.executeQuery(sq);
					if (rs.next())
					{
						sq = (new StringBuilder("select * from ")).append(rs.getString("reason")).append("_tree where chain_name='").append(module_name).append("'").toString();
						rs = db.executeQuery(sq);
						if (rs.next())
						{
							String url = (new StringBuilder("images/erpPlatform/designSub/")).append(rs.getString("picture")).toString();
							out.println(url);
						}
					}
				}
				db.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
